<template>
    <div style="width: 100%;height: 100%;position: relative">
        <Spin size="large" fix v-if="Loading"></Spin>
        <Form :label-width="180" ref="formValidate" :model="formValidate" id="form"
              :rules="ruleValidate">
            <table>
                <tr>
                    <td>
                        <Form-item label="公示开始时间:" prop="tpbl0017">
                            <DatePicker type="date" v-model="formValidate.tpbl0017" placeholder="请选择公示开始时间"
                                        :options="options0017"
                                        style="width: 300px" @on-change="change0017"  :editable="false"></DatePicker>
                        </Form-item>
                    </td>
                    <td>
                        <Form-item label="公示结束时间:" prop="tpbl0018">
                            <DatePicker type="date" v-model="formValidate.tpbl0018" placeholder="请选择公示结束时间"
                                        :options="options0018"
                                        style="width: 300px"  :editable="false"></DatePicker>
                        </Form-item>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <Form-item label="公示反馈意见:" prop="tpbl0013">
                            <c-text-area v-model="formValidate.tpbl0013" :max-length="100" :row="2" width="890"
                                         placeholder="请输入评议现场意见"/>
                        </Form-item>
                    </td>
                </tr>
                <tr>
                    <td>
                        <Form-item label="公示退回原因:" prop="tpbl0006">
                            <c-dict-select v-model="formValidate.tpbl0006" dictCode="reject_reason" :width="300"
                                           showKeys="03,05,06,999"/>
                        </Form-item>
                    </td>
                    <td>
                        <Form-item label="公示终止原因:" prop="tpbl0007">
                            <c-dict-select v-model="formValidate.tpbl0007" dictCode="terminate_reason" :width="300"
                                           showKeys="03,05,06,999"/>
                        </Form-item>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <Form-item label="办理意见说明:" prop="opmemo">
                            <c-text-area v-model="formValidate.opmemo" :max-length="100" :row="3" width="890"
                                         placeholder="请输入办理意见说明"/>
                        </Form-item>
                    </td>

                </tr>
            </table>
        </Form>
    </div>
</template>

<script>
    /**
     * 审批公示
     */
    import {CommonMixin} from '@/views/common/js/CommonMixin'

    export default {
        components: {},
        mixins: [CommonMixin],
        name: "handle03",
        data() {
            return {
                Loading: false,
                familyInfo: {},
                formValidate: {},
                disabled: true,
                information: "",
                ruleValidate: {
                    tpbl0017: [
                        {required: true, message: '公示开始时间不能为空!', trigger: 'blur', trigger: 'change', pattern: /.+/}
                    ],
                    tpbl0018: [
                        {required: true, message: '公示结束时间不能为空!', trigger: 'blur', trigger: 'change', pattern: /.+/}
                    ],
                    tpbl0013: [
                        {required: true, message: '公示反馈意见不能为空!', trigger: 'blur',}
                    ],
                    opmemo: [
                        {required: true, message: '办理意见说明不能为空!', trigger: 'blur',}
                    ],
                    tpbl0006: [
                        {required: false, message: '退回原因不能为空!', trigger: 'change',}
                    ],
                    tpbl0007: [
                        {required: false, message: '终止原因不能为空!', trigger: 'change',}
                    ],

                },
                nowDate: "",
                options0017: {
                    disabledDate: (function (date) {
                        var nowDate = this.nowDate;
                        return date && date.valueOf() > nowDate;
                    }).bind(this)
                },
                options0018: {
                    disabledDate: (function (date) {
                        if (this.formValidate.tpbl0017) {
                            return date.valueOf() < new Date(this.formValidate.tpbl0017) || date.valueOf() > this.nowDate;
                        } else {
                            return date && date.valueOf() > this.nowDate;
                        }
                    }).bind(this)
                }
            }
        },
        methods: {
            change0017(e) {
                if (this.formValidate.tpbl0018) {
                    if (this.formValidate.tpbl0017 > this.formValidate.tpbl0018) {
                        this.$delete(this.formValidate, 'tpbl0018');
                    }
                }
            },
            check(name) {
                this.setRequired(name, this.ruleValidate);
                var infor = false;
                this.$refs['formValidate'].validate((valid) => {
                    if (valid) {
                        infor = this.formValidate;
                    }
                })
                return infor;
            }
        },
        created() {
            var that = this;
            Promise.all([
                new Promise((resolve, reject) => {
                    this.getServerTime(resolve);
                }),
            ]).then(res => {
                that.nowDate = res[0];
            })
        }
    }
</script>

<style scoped src="../../../common/css/rightTip.css">


</style>
